#include<bits/stdc++.h>
using namespace std;
#define N 100005
int T,n,m,L,V,p[N],num,cnt,t[1000005],maxx;
struct node{
    int a,v0,d;
};
node car[N];
inline int read()
{
    int x=0;char ch;
    ch=getchar();
    while(ch>'9'||ch<'0') ch=getchar();
    while(ch>='0'&&ch<='9')
    {
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    T=read();
    while(T--)
    {
        num=0;maxx=0;cnt=0;
        memset(car,0,sizeof(car));
        memset(t,0,sizeof(t));
        memset(p,0,sizeof(p));
        n=read();m=read();L=read();V=read();
        for(int i=1;i<=n;i++)
        {
            car[i].d=read();
            car[i].v0=read();
            car[i].a=read();
        }
        for(int i=1;i<=m;i++)
        {
            p[i]=read();
            /*for(int j=p[i-1]+1;j<=p[i];j++)
                t[j]=i;*/
        }
        for(int i=1;i<=n;i++)
        {
            if(car[i].a==0)
            {
                if(car[i].v0>V&&car[i].d<=p[m])
                {
                    num++;
                    //maxx=max(maxx,t[car[i].d]);
                }
            }
            if(car[i].a>0)
            {
                if(car[i].v0*car[i].v0+2*car[i].a*(p[m]-car[i].d)>V*V)
                {
                    num++;
                    /*if(car[i].v0>V) maxx=max(maxx,t[car[i].d]);
                    else
                    {
                        double dis=(V+car[i].v0)*(V-car[i].v0)/(2*car[i].a);
                        maxx=max(maxx,t[int(dis+1)]);
                    }*/
                }
            }
            /*if(car[i].a<0)
            {
                if(car[i].v0*car[i].v0+2*car[i].a*(p[car[i].d]-car[i].d)>V*V)
                {
                    num++;
                }
            }*/
        }
        printf("%d %d\n",num,m-1);
    }
    return 0;
}
